<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QPictureIO Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QPictureIO Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QPictureIO class contains parameters for loading and saving
pictures. <a href="#details">More...</a></p>

<h3>Methods</h3><ul><li><div class="fn" /><b><a href="qpictureio.html#QPictureIO">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qpictureio.html#QPictureIO-2">__init__</a></b> (<i>self</i>, QIODevice&#160;<i>ioDevice</i>, str&#160;<i>format</i>)</li><li><div class="fn" /><b><a href="qpictureio.html#QPictureIO-3">__init__</a></b> (<i>self</i>, QString&#160;<i>fileName</i>, str&#160;<i>format</i>)</li><li><div class="fn" />QString <b><a href="qpictureio.html#description">description</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qpictureio.html#fileName">fileName</a></b> (<i>self</i>)</li><li><div class="fn" />str <b><a href="qpictureio.html#format">format</a></b> (<i>self</i>)</li><li><div class="fn" />float <b><a href="qpictureio.html#gamma">gamma</a></b> (<i>self</i>)</li><li><div class="fn" />QIODevice <b><a href="qpictureio.html#ioDevice">ioDevice</a></b> (<i>self</i>)</li><li><div class="fn" />str <b><a href="qpictureio.html#parameters">parameters</a></b> (<i>self</i>)</li><li><div class="fn" />QPicture <b><a href="qpictureio.html#picture">picture</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qpictureio.html#quality">quality</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qpictureio.html#read">read</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qpictureio.html#setDescription">setDescription</a></b> (<i>self</i>, QString)</li><li><div class="fn" /><b><a href="qpictureio.html#setFileName">setFileName</a></b> (<i>self</i>, QString)</li><li><div class="fn" /><b><a href="qpictureio.html#setFormat">setFormat</a></b> (<i>self</i>, str)</li><li><div class="fn" /><b><a href="qpictureio.html#setGamma">setGamma</a></b> (<i>self</i>, float)</li><li><div class="fn" /><b><a href="qpictureio.html#setIODevice">setIODevice</a></b> (<i>self</i>, QIODevice)</li><li><div class="fn" /><b><a href="qpictureio.html#setParameters">setParameters</a></b> (<i>self</i>, str)</li><li><div class="fn" /><b><a href="qpictureio.html#setPicture">setPicture</a></b> (<i>self</i>, QPicture)</li><li><div class="fn" /><b><a href="qpictureio.html#setQuality">setQuality</a></b> (<i>self</i>, int)</li><li><div class="fn" /><b><a href="qpictureio.html#setStatus">setStatus</a></b> (<i>self</i>, int)</li><li><div class="fn" />int <b><a href="qpictureio.html#status">status</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qpictureio.html#write">write</a></b> (<i>self</i>)</li></ul><h3>Static Methods</h3><ul><li><div class="fn" /><b><a href="qpictureio.html#defineIOHandler">defineIOHandler</a></b> (str&#160;<i>format</i>, str&#160;<i>header</i>, str&#160;<i>flags</i>, callable&#160;<i>read_picture</i>, callable&#160;<i>write_picture</i>)</li><li><div class="fn" />list-of-QByteArray <b><a href="qpictureio.html#inputFormats">inputFormats</a></b> ()</li><li><div class="fn" />list-of-QByteArray <b><a href="qpictureio.html#outputFormats">outputFormats</a></b> ()</li><li><div class="fn" />QByteArray <b><a href="qpictureio.html#pictureFormat">pictureFormat</a></b> (QString&#160;<i>fileName</i>)</li><li><div class="fn" />QByteArray <b><a href="qpictureio.html#pictureFormat-2">pictureFormat</a></b> (QIODevice)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QPictureIO class contains parameters for loading and saving
pictures.</p>
<p>QPictureIO contains a <a href="qiodevice.html">QIODevice</a>
object that is used for picture data I/O. The programmer can
install new picture file formats in addition to those that Qt
provides.</p>
<p>You don't normally need to use this class; <a href="qpicture.html#load">QPicture.load</a>(), <a href="qpicture.html#save">QPicture.save</a>().</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QPictureIO" />QPictureIO.__init__ (<i>self</i>)</h3><p>Constructs a <a class="obsolete" href="qpictureio.html">QPictureIO</a> object with all parameters set to
zero.</p>


<h3 class="fn"><a name="QPictureIO-2" />QPictureIO.__init__ (<i>self</i>, <a href="qiodevice.html">QIODevice</a>&#160;<i>ioDevice</i>, str&#160;<i>format</i>)</h3><p>Constructs a <a class="obsolete" href="qpictureio.html">QPictureIO</a> object with the I/O device
<i>ioDevice</i> and a <i>format</i> tag.</p>


<h3 class="fn"><a name="QPictureIO-3" />QPictureIO.__init__ (<i>self</i>, QString&#160;<i>fileName</i>, str&#160;<i>format</i>)</h3><p>Constructs a <a class="obsolete" href="qpictureio.html">QPictureIO</a> object with the file name <i>fileName</i>
and a <i>format</i> tag.</p>


<h3 class="fn"><a name="defineIOHandler" />QPictureIO.defineIOHandler (str&#160;<i>format</i>, str&#160;<i>header</i>, str&#160;<i>flags</i>, callable&#160;<i>read_picture</i>, callable&#160;<i>write_picture</i>)</h3><p>The <i>read_picture</i> argument may also be None.</p><p>The <i>write_picture</i> argument may also be None.</p><p>Defines a picture I/O handler for the picture format called
<i>format</i>, which is recognized using the regular expression
defined in <i>header</i>, read using <i>readPicture</i> and written
using <i>writePicture</i>.</p>
<p><i>flags</i> is a string of single-character flags for this
format. The only flag defined currently is T (upper case), so the
only legal value for <i>flags</i> are "T" and the empty string. The
"T" flag means that the picture file is a text file, and Qt should
treat all newline conventions as equivalent. (XPM files and some
PPM files are text files for example.)</p>
<p><i>format</i> is used to select a handler to write a <a href="qpicture.html">QPicture</a>; <i>header</i> is used to select a
handler to read an picture file.</p>
<p>If <i>readPicture</i> is a null pointer, the <a class="obsolete" href="qpictureio.html">QPictureIO</a> will not be able
to read pictures in <i>format</i>. If <i>writePicture</i> is a null
pointer, the <a class="obsolete" href="qpictureio.html">QPictureIO</a> will not be able to write pictures in
<i>format</i>. If both are null, the <a class="obsolete" href="qpictureio.html">QPictureIO</a> object is valid but useless.</p>
<p>Example:</p>
<pre class="cpp">
 <span class="type">void</span> readSVG(<span class="type"><a href="qpictureio.html">QPictureIO</a></span> <span class="operator">*</span>picture)
 {
     <span class="comment">// read the picture using the picture-&gt;ioDevice()</span>
 }

 <span class="type">void</span> writeSVG(<span class="type"><a href="qpictureio.html">QPictureIO</a></span> <span class="operator">*</span>picture)
 {
     <span class="comment">// write the picture using the picture-&gt;ioDevice()</span>
 }

     <span class="comment">// add the SVG picture handler</span>
     <span class="comment">// ...</span>
</pre>
<p>Before the regular expression test, all the 0 bytes in the file
header are converted to 1 bytes. This is done because when Qt was
ASCII-based, <a href="qregexp.html">QRegExp</a> could not handle 0
bytes in strings.</p>
<p>The regexp is only applied on the first 14 bytes of the
file.</p>
<p>(Note that if one handlerIO supports writing a format and
another supports reading it, Qt supports both reading and writing.
If two handlers support the same operation, Qt chooses one
arbitrarily.)</p>


<h3 class="fn"><a name="description" />QString QPictureIO.description (<i>self</i>)</h3><p>Returns the picture description string.</p>
<p><b>See also</b> <a href="qpictureio.html#setDescription">setDescription</a>().</p>


<h3 class="fn"><a name="fileName" />QString QPictureIO.fileName (<i>self</i>)</h3><p>Returns the file name currently set.</p>
<p><b>See also</b> <a href="qpictureio.html#setFileName">setFileName</a>().</p>


<h3 class="fn"><a name="format" />str QPictureIO.format (<i>self</i>)</h3><p>Returns the picture format string or 0 if no format has been
explicitly set.</p>
<p><b>See also</b> <a href="qpictureio.html#setFormat">setFormat</a>().</p>


<h3 class="fn"><a name="gamma" />float QPictureIO.gamma (<i>self</i>)</h3><p>Returns the gamma value at which the picture will be viewed.</p>
<p><b>See also</b> <a href="qpictureio.html#setGamma">setGamma</a>().</p>


<h3 class="fn"><a name="inputFormats" />list-of-QByteArray QPictureIO.inputFormats ()</h3><p>Returns a sorted list of picture formats that are supported for
picture input.</p>


<h3 class="fn"><a name="ioDevice" /><a href="qiodevice.html">QIODevice</a> QPictureIO.ioDevice (<i>self</i>)</h3><p>Returns the IO device currently set.</p>
<p><b>See also</b> <a href="qpictureio.html#setIODevice">setIODevice</a>().</p>


<h3 class="fn"><a name="outputFormats" />list-of-QByteArray QPictureIO.outputFormats ()</h3><p>Returns a sorted list of picture formats that are supported for
picture output.</p>


<h3 class="fn"><a name="parameters" />str QPictureIO.parameters (<i>self</i>)</h3><p>Returns the picture's parameters string.</p>
<p><b>See also</b> <a href="qpictureio.html#setParameters">setParameters</a>().</p>


<h3 class="fn"><a name="picture" /><a href="qpicture.html">QPicture</a> QPictureIO.picture (<i>self</i>)</h3><p>Returns the picture currently set.</p>
<p><b>See also</b> <a href="qpictureio.html#setPicture">setPicture</a>().</p>


<h3 class="fn"><a name="pictureFormat" /><a href="qbytearray.html">QByteArray</a> QPictureIO.pictureFormat (QString&#160;<i>fileName</i>)</h3><p>Returns a string that specifies the picture format of the file
<i>fileName</i>, or null if the file cannot be read or if the
format is not recognized.</p>


<h3 class="fn"><a name="pictureFormat-2" /><a href="qbytearray.html">QByteArray</a> QPictureIO.pictureFormat (<a href="qiodevice.html">QIODevice</a>)</h3><p>This is an overloaded function.</p>
<p>Returns a string that specifies the picture format of the
picture read from IO device <i>d</i>, or 0 if the device cannot be
read or if the format is not recognized.</p>
<p>Make sure that <i>d</i> is at the right position in the device
(for example, at the beginning of the file).</p>
<p><b>See also</b> <a class="compat" href="qiodevice-qt3.html#at">QIODevice.at</a>().</p>


<h3 class="fn"><a name="quality" />int QPictureIO.quality (<i>self</i>)</h3><p>Returns the quality of the written picture, related to the
compression ratio.</p>
<p><b>See also</b> <a href="qpictureio.html#setQuality">setQuality</a>() and <a href="qpicture.html#save">QPicture.save</a>().</p>


<h3 class="fn"><a name="read" />bool QPictureIO.read (<i>self</i>)</h3><p>Reads an picture into memory and returns true if the picture was
successfully read; otherwise returns false.</p>
<p>Before reading an picture you must set an IO device or a file
name. If both an IO device and a file name have been set, the IO
device will be used.</p>
<p>Setting the picture file format string is optional.</p>
<p>Note that this function does <i>not</i> set the <a href="qpictureio.html#format">format</a> used to read the picture. If
you need that information, use the <a href="qpictureio.html#pictureFormat">pictureFormat</a>() static
functions.</p>
<p>Example:</p>
<pre class="cpp">
         <span class="type"><a href="qpictureio.html">QPictureIO</a></span> iio;
         <span class="type"><a href="qpixmap.html">QPixmap</a></span>  pixmap;
         iio<span class="operator">.</span>setFileName(<span class="string">"vegeburger.pic"</span>);
         <span class="keyword">if</span> (iio<span class="operator">.</span>read()) {        <span class="comment">// OK</span>
             <span class="type"><a href="qpicture.html">QPicture</a></span> picture <span class="operator">=</span> iio<span class="operator">.</span>picture();
             <span class="type"><a href="qpainter.html">QPainter</a></span> painter(<span class="operator">&amp;</span>pixmap);
             painter<span class="operator">.</span>drawPicture(<span class="number">0</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> picture);
         }
</pre>
<p><b>See also</b> <a href="qpictureio.html#setIODevice">setIODevice</a>(), <a href="qpictureio.html#setFileName">setFileName</a>(), <a href="qpictureio.html#setFormat">setFormat</a>(), <a href="qpictureio.html#write">write</a>(), and <a href="qpixmap.html#load">QPixmap.load</a>().</p>


<h3 class="fn"><a name="setDescription" />QPictureIO.setDescription (<i>self</i>, QString)</h3><p>Sets the picture description string for picture handlers that
support picture descriptions to <i>description</i>.</p>
<p>Currently, no picture format supported by Qt uses the
description string.</p>
<p><b>See also</b> <a href="qpictureio.html#description">description</a>().</p>


<h3 class="fn"><a name="setFileName" />QPictureIO.setFileName (<i>self</i>, QString)</h3><p>Sets the name of the file to read or write an picture from to
<i>fileName</i>.</p>
<p><b>See also</b> <a href="qpictureio.html#fileName">fileName</a>() and <a href="qpictureio.html#setIODevice">setIODevice</a>().</p>


<h3 class="fn"><a name="setFormat" />QPictureIO.setFormat (<i>self</i>, str)</h3><p>Sets the picture format to <i>format</i> for the picture to be
read or written.</p>
<p>It is necessary to specify a format before writing an picture,
but it is not necessary to specify a format before reading an
picture.</p>
<p>If no format has been set, Qt guesses the picture format before
reading it. If a format is set the picture will only be read if it
has that format.</p>
<p><b>See also</b> <a href="qpictureio.html#read">read</a>(),
<a href="qpictureio.html#write">write</a>(), and <a href="qpictureio.html#format">format</a>().</p>


<h3 class="fn"><a name="setGamma" />QPictureIO.setGamma (<i>self</i>, float)</h3><p>Sets the gamma value at which the picture will be viewed to
<i>gamma</i>. If the picture format stores a gamma value for which
the picture is intended to be used, then this setting will be used
to modify the picture. Setting to 0.0 will disable gamma correction
(i.e. any specification in the file will be ignored).</p>
<p>The default value is 0.0.</p>
<p><b>See also</b> <a href="qpictureio.html#gamma">gamma</a>().</p>


<h3 class="fn"><a name="setIODevice" />QPictureIO.setIODevice (<i>self</i>, <a href="qiodevice.html">QIODevice</a>)</h3><p>Sets the IO device to be used for reading or writing an
picture.</p>
<p>Setting the IO device allows pictures to be read/written to any
block-oriented <a href="qiodevice.html">QIODevice</a>.</p>
<p>If <i>ioDevice</i> is not null, this IO device will override
file name settings.</p>
<p><b>See also</b> <a href="qpictureio.html#setFileName">setFileName</a>().</p>


<h3 class="fn"><a name="setParameters" />QPictureIO.setParameters (<i>self</i>, str)</h3><p>Sets the picture's parameter string to <i>parameters</i>. This
is for picture handlers that require special parameters.</p>
<p>Although the current picture formats supported by Qt ignore the
parameters string, it may be used in future extensions or by
contributions (for example, JPEG).</p>
<p><b>See also</b> <a href="qpictureio.html#parameters">parameters</a>().</p>


<h3 class="fn"><a name="setPicture" />QPictureIO.setPicture (<i>self</i>, <a href="qpicture.html">QPicture</a>)</h3><p>Sets the picture to <i>picture</i>.</p>
<p><b>See also</b> <a href="qpictureio.html#picture">picture</a>().</p>


<h3 class="fn"><a name="setQuality" />QPictureIO.setQuality (<i>self</i>, int)</h3><p>Sets the quality of the written picture to <i>q</i>, related to
the compression ratio.</p>
<p><i>q</i> must be in the range -1..100. Specify 0 to obtain small
compressed files, 100 for large uncompressed files. (-1 signifies
the default compression.)</p>
<p><b>See also</b> <a href="qpictureio.html#quality">quality</a>()
and <a href="qpicture.html#save">QPicture.save</a>().</p>


<h3 class="fn"><a name="setStatus" />QPictureIO.setStatus (<i>self</i>, int)</h3><p>Sets the picture IO status to <i>status</i>. A non-zero value
indicates an error, whereas 0 means that the IO operation was
successful.</p>
<p><b>See also</b> <a href="qpictureio.html#status">status</a>().</p>


<h3 class="fn"><a name="status" />int QPictureIO.status (<i>self</i>)</h3><p>Returns the picture's IO status. A non-zero value indicates an
error, whereas 0 means that the IO operation was successful.</p>
<p><b>See also</b> <a href="qpictureio.html#setStatus">setStatus</a>().</p>


<h3 class="fn"><a name="write" />bool QPictureIO.write (<i>self</i>)</h3><p>Writes an picture to an IO device and returns true if the
picture was successfully written; otherwise returns false.</p>
<p>Before writing an picture you must set an IO device or a file
name. If both an IO device and a file name have been set, the IO
device will be used.</p>
<p>The picture will be written using the specified picture
format.</p>
<p>Example:</p>
<pre class="cpp">
         <span class="type"><a href="qpictureio.html">QPictureIO</a></span> iio;
         <span class="type"><a href="qpicture.html">QPicture</a></span>   picture;
         <span class="type"><a href="qpainter.html">QPainter</a></span> painter(<span class="operator">&amp;</span>picture);
         painter<span class="operator">.</span>drawPixmap(<span class="number">0</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> pixmap);
         iio<span class="operator">.</span>setPicture(picture);
         iio<span class="operator">.</span>setFileName(<span class="string">"vegeburger.pic"</span>);
         iio<span class="operator">.</span>setFormat(<span class="string">"PIC"</span>);
         <span class="keyword">if</span> (iio<span class="operator">.</span>write())
             <span class="keyword">return</span> <span class="keyword">true</span>; <span class="comment">// returned true if written successfully</span>
</pre>
<p><b>See also</b> <a href="qpictureio.html#setIODevice">setIODevice</a>(), <a href="qpictureio.html#setFileName">setFileName</a>(), <a href="qpictureio.html#setFormat">setFormat</a>(), <a href="qpictureio.html#read">read</a>(), and <a href="qpixmap.html#save">QPixmap.save</a>().</p>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;snapshot-4.9.5-9eb6aac99275 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt&#160;4.8.3</td></tr></table></div></address></body></html>